home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group99a.txt
/
000069_icon-group-sender _Tue Mar 30 15:32:46 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id PAA14056
for icon-group-addresses; Tue, 30 Mar 1999 15:32:39 -0700 (MST)
Message-Id: <199903302232.PAA14056@baskerville.CS.Arizona.EDU>
Date: Tue, 30 Mar 1999 16:04:23 -0600
From: Steve Graham <graham@cowboy.biomed.com>
X-Accept-Language: en
To: Icon Mailing List <icon-group@optima.CS.Arizona.EDU>
Subject: [Fwd: Problem reading binary file]
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Hello again.
Turns out that the problem with this was that the 7th character was an
ASCII 26 (^Z) and Icon would not read any further than that. I created
a 2nd file with a ^Z in a different position and got a similar result.
This is despite the fact that there were over 25,000 characters
following the Control Z.
So, my question is: Why does Icon stop reading when it hits a ^Z? I
can kind of understand this if I were reading a text file; but I was
specifically using reads() because this is a binary file? Should not
reads() support all 256 ASCII codes and only stop reading when there are
REALLY no more characters to read? I ended up using another language,
which was significantly harder for me, to read the binary characters.
In Icon's defense, I notice that when I TYPE the above-mentioned 2nd
file, I only see the characters occurring prior to the ^Z. And I do not
want it to appear that I am questioning Icon's usefulness. It is
normally one of the 1st languages I choose for utilities of this type.
Comments?
Steve Graham
===
Steve Graham wrote:
>
> Hello.
>
> I am using MS-DOS Icon 9.1 to read a binary file. After reading 6
> characters, the program apparently quits reading. I have attached the
> relevant portion of the code:
>
> -------------------------- Code ------------------------------
> procedure main(args)
> #
> cnt := 0
> in := open(args[1],"r") | stop("Unable to open ",args[1])
> out := open(args[2],"w") | stop("Unable to open ",args[2])
> while character := reads(in,1) do {
> write(character," -->", ord(character))
> cnt := cnt+1
> }
> close(in,out)
> write(cnt," characters transferred")
> end
> -----------------------End of Code-------------------------
>
> I invoke the program with:
>
> word r99-0059.doc r99-0059.txt
>
> I get output of (some unprintable characters are represent by _):
>
> - -->208
> - -->207
> -->17
> _ -->224
> � -->161
> _ -->177
> 6 characters transferred
>
> Any ideas?
>
> Thanks in advance.
>
> -- Steve
>
> ______________________________________________________
>
> Steve Graham
> Laboratory Corporation of America (LabCorp)
> 12160 Abrams Road, Suite 601
> Dallas, Texas 75243
>
> E-mail: graham@cowboy.biomed.com
> Phone: 972.643.6124 (direct to desk)
> 972.437.5255 ext 5224
> FAX: 972.454.1040
> _______________________________________________________